package com.xyh;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class PoliceController {
    @RequestMapping(value = "/call/{id}",method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
   public Police call(@PathVariable Integer id, HttpServletRequest httpServletRequest){
       Police police=new Police();
       police.setAge(33);
       police.setMessage(httpServletRequest.getRequestURL().toString());
       police.setName("angus");
       police.setId(id);
       return police;
   }
   @RequestMapping(value = "/hello/{name}",method = RequestMethod.GET)
   public String hello(@PathVariable String name){
        return "Hello,"+name;
   }
    @RequestMapping(value = "/hellowd",method = RequestMethod.GET)
   public String helloWithOutArg(){
        return "Hello World";
   }

}
